package com.x.erp.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.x.erp.model.CarType;
import com.x.erp.model.Color;
import com.x.erp.rpc.CarTypeRpcService;
import com.x.erp.rpc.ColorRpcService;
import com.x.erp.util.Constant;
import com.x.framework.controller.BaseController;
import com.x.framework.controller.ResultCode;
import com.x.framework.controller.ResultModel;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/carBase")
public class CarBaseController extends BaseController{

	@Reference
	private ColorRpcService colorRpcService;

	@Reference
	private CarTypeRpcService carTypeRpcService;

	/**
	 * 获取车辆基础参数
	 * @return
	 */
	@RequestMapping("/getCarBaseParam")
	public ResultModel getCarBaseParam(){
		Map<String, Object> carBaseParam = new HashMap<>();
		Color color = new Color();
		color.setColorIn(1);
		carBaseParam.put("baseCarInColorOptions", colorRpcService.selectColorList(color));//车辆内饰颜色
		color.setColorIn(null);
		color.setColorOut(1);
		carBaseParam.put("baseCarOutColorOptions", colorRpcService.selectColorList(color));//车辆外观颜色
		carBaseParam.put("baseCarEnvironOptions", Constant.BASE_CAR_ENVIRON_OPTIONS);//环保等级
		carBaseParam.put("baseCarGearboxOptions", Constant.BASE_CAR_GEARBOX_OPTIONS);//变速箱
		carBaseParam.put("baseCarFuelOptions", Constant.BASE_CAR_FUEL_OPTIONS);//燃油类型
		List<Map<String, Object>> baseCarPurposeOptions = new ArrayList<>();
		Map<String, Object> carPurpose = new HashMap<>();
		carPurpose.put("purposeKey", 1);
		carPurpose.put("purposeValue", "营运");
		baseCarPurposeOptions.add(carPurpose);
		carPurpose = new HashMap<>();
		carPurpose.put("purposeKey", 2);
		carPurpose.put("purposeValue", "非营运");
		baseCarPurposeOptions.add(carPurpose);
		carPurpose = new HashMap<>();
		carPurpose.put("purposeKey", 3);
		carPurpose.put("purposeValue", "营转非");
		baseCarPurposeOptions.add(carPurpose);
		carBaseParam.put("baseCarPurposeOptions", baseCarPurposeOptions);//使用性质
		carBaseParam.put("baseCarTypeOptions", carTypeRpcService.selectCarTypeList(new CarType()));//车身类型
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", carBaseParam);
	}

}
